<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2018/8/1
 * Time: 上午10:54
 */

namespace app\common\service;


use app\common\model\Sign;
use think\Exception;

class SignService extends BaseService
{
    protected $signModel;
    public function __construct()
    {
        $this->signModel=new Sign();
    }

    /**
     * 新增签到记录
     * @param $addInfo
     * @return int|string
     */
    public function addSign($addInfo){
        $addInfo['create_time']=date('Y-m-d H:i:s');
        return $this->signModel->insertGetId($addInfo);
    }

    /**
     * 修改签到状态
     * @param $appiyid
     * @return $this|bool
     */
    public function saveSign($appiyid){
        try{
            $save=[
                'status'=>1,
                'sign_time'=>date('Y-m-d H:i:s')
            ];
            return $this->signModel->where('appiyid',$appiyid)->save($save);
        }catch (Exception $ex){
            echo 'Exception';
            return false;
        }
    }

    /**
     * @param $where
     * @return array|bool
     */
    public function querySign($where){
        try{
            $re=$this->signModel->where($where)->select();
            if($re){
                return $re->toArray();
            }else{
                return false;
            }
        }catch (Exception $ex){
            echo 'exception';
            return false;
        }
    }

}